<template>
  <a-spin
    :spinning="confirmLoading"
    style="padding-bottom: 20px"
    class="fillAudit"
  >
    <p class="info_title">审核信息</p>
    <a-row style="padding: 0px 20px" v-if="!!taskInfo">
      <p class="title">任务信息</p>

      <a-col :span="12" style="margin-bottom: 16px" class="item">
        任务名称：{{ taskInfo.taskName }}
      </a-col>
      <a-col :span="12" style="margin-bottom: 16px" class="item">
        核算标准：{{ taskInfo.standardName }}
      </a-col>
      <a-col :span="12" style="margin-bottom: 16px" class="item">
        填报周期：{{ taskInfo.fillingTime.replace(",", "至") }}
      </a-col>
      <a-col :span="12" style="margin-bottom: 16px" class="item">
        创 建 人 ：{{ taskInfo.createBy }}
      </a-col>
      <a-col :span="12" style="margin-bottom: 16px" class="item">
        创建时间：{{ taskInfo.createTime }}
      </a-col>

      <a-col :span="24" style="margin-bottom: 16px">
        <p class="title">碳排放量</p>
        <a-table
          :columns="columns"
          :data-source="emission"
          :pagination="false"
        ></a-table>
      </a-col>
      <a-col
        :span="24"
        style="margin-bottom: 16px"
        v-for="(item, index) in facilitiesBoundaryList"
        :key="index"
      >
        <p class="title">{{ item.facilitiesName }}-{{ item.boundaryName }}</p>
        <a-table
          :pagination="false"
          :columns="item.header"
          :data-source="item.data"
          size="small"
        />
      </a-col>
    </a-row>
    <!-- </div> -->
  </a-spin>
</template>

<script>
import { httpAction, getAction, postAction } from "@/api/manage";
import { auditInformant } from "@/api/api.js";
const columns = [
  {
    dataIndex: "boundaryName",
    title: "源类别",
    key: "boundaryName",
    scopedSlots: { customRender: "boundaryName" },
  },
  {
    title: "排放量 单位：tCO₂e",
    dataIndex: "emission",
    key: "emission",
  },
];

export default {
  data() {
    return {
      taskInfo: null,
      columns,
      emission: null,
      facilitiesBoundaryList: null,
      confirmLoading: false,
    };
  },

  methods: {
    onChange() {},
    handleSelectChange() {},
    submitForm() {
      const that = this;
      // 触发表单验证
      this.$refs.form.validate((valid) => {
        if (valid) {
          that.confirmLoading = true;
          let httpurl = "";
          let method = "";
          if (!this.model.id) {
            httpurl += this.url.add;
            method = "post";
          } else {
            httpurl += this.url.edit;
            method = "put";
          }
          httpAction(httpurl, this.model, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.$emit("ok");
              } else {
                that.$message.warning(res.message);
              }
            })
            .finally(() => {
              that.confirmLoading = false;
            });
        }
      });
      // postAction("/check/third-party/add", this.model).then((res) => {

      //   console.log(res);
      // });
    },
  },
  created() {
    var param = { businessKey: this.$route.query.businessKey };
    auditInformant(param).then((res) => {
      if (res.result) {
        this.taskInfo = res.result.taskInfo;
        this.emission = res.result.emissionStatList;
        this.facilitiesBoundaryList = res.result.facilitiesBoundaryList;
      }
    });
  },
  computed: {},
};
</script>

<style lang="scss" scoped>
.fillAudit {
  background: #fbfcfd;
  margin: 0 0 40px 0;
  .info_title {
    padding: 10px;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #409eff;
  }
  .title {
    margin: 18px 0 12px;
    font-size: 16px;
    font-weight: 600;
    color: #000;
  }
}
</style>